home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-06-23 | 1.7 KB | 67 lines | [TEXT/MPS ] |
- FUNCTION LongToString(theLong:longint):str255;
- {simple glue routine takes integer or longint and returns string containing value}
- var
- theString: str255;
- begin
- NumToString(theLong,theString);
- LongToString := theString;
- end;
-
- FUNCTION LongToHexString (number: UNIV longint): str255;
- {takes longint and returns a string containing value in hex}
- CONST
- digits = '0123456789ABCDEFX';
- VAR
- hex: Str255;
- hexIndex: INTEGER;
- negative: BOOLEAN;
- BEGIN
- hex[0]:=chr(9);{set length of hex to 9}
- hex[1] := '$';
- IF number < 0 THEN BEGIN
- number:=bitAnd(number,maxLongint);
- { mask off leading negative bit}
- negative := true;
- END
- ELSE negative := false;
-
- FOR hexIndex := 9 DOWNTO 3 DO BEGIN
- hex[hexIndex]:=digits[1+(numberMOD 16)];
- {put digit into hex string}
- number:= number DIV longint(16);
- END;
-
- IF negative THEN
- hex[2]:=digits[1+(number MOD 16) + 8]
- ELSE hex[2]:=digits[1+(number MOD 16)];
- LongToHexString := hex;
- END;
-
- FUNCTION PtrToHexString( aPtr: UNIV ptr): str255;
- {takes Ptr and returns string containing value in hex. StripAddress is called on the Ptr.}
- CONST
- digits = '0123456789ABCDEF';
- VAR
- hex: string[10];
- hexIndex: INTEGER;
- number: longint;
- BEGIN
- hex[0] := chr(9); {set length of hex to 9}
- hex[1] := '$';
- number := longint(StripAddress(aPtr));
- FOR hexIndex := 9 DOWNTO 2 DO
- BEGIN
- hex[hexIndex]:=digits[1+(number MOD16)]; {put digit into hex string}
- number := number DIV longint(16);
- END;
- PtrToHexString := hex;
- END;
-
- FUNCTION BooleanToString(theBoolean:Boolean): str255;
- { glue routine takes boolean and returns string containing value}
- begin
- if theBoolean
- then BooleanToString := 'true'
- else BooleanToString := 'false';
- end;
-